home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-03-26 | 5.5 KB | 205 lines | [TEXT/MPS ] |
- UNIT BLInit; {•••• Initialization routines ••••}
-
- INTERFACE
-
- USES Memtypes,QuickDraw,OSIntf,ToolIntf,
- PackIntf,FixMath,ObjIntf,BLObject;
-
- PROCEDURE InitBigList;
- PROCEDURE SetUpMenus;
- PROCEDURE SetUpPseudoDialog;
-
- IMPLEMENTATION
- {$S SegInit}
- {••••••••••••••••••••••••••••••••••••••••••••••••}
- PROCEDURE InitBigList;
- PROCEDURE SetUpMultiFinder; {Set “wneExists”}
- CONST WNETrapNum = $60; {Nº of “WaitNextEvent”}
- UnImplTrap = $9F; {Unimplemented trap #}
- VAR world : SysEnvRec;
- error : OSErr;
- BEGIN
- error:= SysEnvirons(1,world);
- IF error = noErr THEN BEGIN
- IF world.machineType<0 THEN ExitToShell;
- wneExists:= (world.machineType >= 0) AND
- (NGetTrapAddress(WNETrapNum,ToolTrap)<>
- NGetTrapAddress(UnImplTrap,ToolTrap));
- END
- ELSE wneExists:= FALSE;
- END;
- BEGIN
- {Basic toolbox initializations}
- MaxApplZone;
- InitGraf(@thePort);
- InitFonts;
- InitWindows;
- InitMenus;
- TEInit;
- InitDialogs(NIL);
- {Event-management globals}
- weAreDone:= FALSE;
- inBckGrnd:= FALSE;
- SetUpMultiFinder;
- dublClick:= FALSE;
- SetPt(lastClikPoint,0,0);
- lastClikTime:= 0;
- FlushEvents(everyEvent,0);
- {Initialize the cursors}
- XCursor:= GetCursor(crossCursor);
- HLock(Handle(XCursor));
- waitCursor:= GetCursor(watchCursor);
- HLock(Handle(waitCursor));
- SetCursor(waitCursor^^);
- {Init. “styleVector” for top of Style menu}
- styleVector[2]:= bold;
- styleVector[3]:= italic;
- styleVector[4]:= underline;
- styleVector[5]:= outline;
- styleVector[6]:= shadow;
- styleVector[7]:= condense;
- styleVector[8]:= extend;
- {Other stuff}
- forNowFI.n:= systemFont;
- forNowFI.s:= 12;
- forNowFI.y:= [];
- defaultFI:= forNowFI;
- entr := CHR( 3);
- cRet := CHR(13);
- left := CHR(28);
- right:= CHR(29);
- up := CHR(30);
- down := CHR(31);
- blnkChr:= ' ';
- blnkPtr:= Ptr(ORD(@blnkChr)+1); {With Munger}
- WITH screenBits.bounds DO BEGIN
- SetRect(zoomArea,left+origH,top+origV,
- right-origH,bottom-origH);
- SetRect(dragArea,left+4,top+24,
- right-4,bottom-4);
- END;
- END;
- {••••••••••••••••••••••••••••••••••••••••••••••••}
- PROCEDURE SetUpMenus;
- BEGIN
- myMenus[1]:= GetMenu(applMID);
- AddResMenu(myMenus[1],'DRVR');
- InsertMenu(myMenus[1],0);
- myMenus[2]:= GetMenu(fileMID);
- InsertMenu(myMenus[2],0);
- myMenus[3]:= GetMenu(editMID);
- InsertMenu(myMenus[3],0);
- myMenus[4]:= GetMenu(fontMID);
- AddResMenu(myMenus[4],'FONT');
- InsertMenu(myMenus[4],0);
- theFontMenu:= myMenus[4];
- myMenus[5]:= GetMenu(stylMID);
- InsertMenu(myMenus[5],0);
- theStylMenu:= myMenus[5];
- SetFontMenu;
- SetSizeMenu;
- SetStylMenu;
- DrawMenuBar;
- END;
- {••••••••••••••••••••••••••••••••••••••••••••••••}
- PROCEDURE CheckMemError;
- VAR e : OSErr;
- BEGIN
- e:= MemError;
- IF e = noErr THEN Exit(CheckMemError);
- SimpleAlert(Concat('Error #',IntString(e)));
- ExitToShell;
- END;
- {••••••••••••••••••••••••••••••••••••••••••••••••}
- { THE DATA MUST START & END WITH A BLANK. }
- PROCEDURE InstallSomeDataInList(v:TVerticalList);
- CONST numberOfEntries = 10000;
- VAR h : Handle;
- s : Str255;
- i,x : LongInt;
- BEGIN
- h:= NewHandle(1);
- CheckMemError;
- s[0]:= blnkChr;
- BlockMove(@s,h^,1);
- x:= 1;
- FOR i:= 1 TO numberOfEntries DO BEGIN
- CASE i MOD 5 OF
- 0:s:= 'What';
- 1:s:= 'fools';
- 2:s:= 'these';
- 3:s:= 'mortals';
- 4:s:= 'be!';
- END;
- s:= Concat(IntString(i),'•',s,blnkChr);
- x:= Munger(h,x,NIL,0,Ptr(ORD(@s)+1),
- Length(s));
- CheckMemError;
- END;
- v.InstallData(h);
- END;
- {••••••••••••••••••••••••••••••••••••••••••••••••}
- PROCEDURE SetUpPseudoDialog;
- VAR r : Rect;
- f : FontIdent;
- theVL : TVerticalList;
- thePB : TPlainButton;
- theTB : TToggleButton;
- the3D : TThreeDButton;
- theT3 : TToggl3DButton;
- theST : TStaticText;
- theIC : TIcon;
- theAN : TAnimation;
- PROCEDURE SetF(nn:INTEGER; ss:Byte; yy:Style);
- BEGIN f.n:= nn; f.s:= ss; f.y:= yy; END;
- BEGIN
- New(fakeDlg);
- SetRect(r,105,50,405,300);
- SetF(systemFont,12,[]);
- fakeDlg.IPseudoDialog(r,
- 'Big List Demonstration',FALSE,f);
- New(theVL);
- SetRect(r, 10, 10,110,240);
- theVL.IVerticalList(r,fakeDlg.fWindow);
- InstallSomeDataInList(theVL);
- fakeDlg.InstallItem(theVL);
- New(thePB);
- SetRect(r,125, 10,280, 10); {Force computation}
- SetF(geneva,9,[bold,extend]);
- thePB.IPlainButton(r,'About…','1',f);
- fakeDlg.InstallItem(thePB);
- New(theTB);
- SetRect(r,125, 45,280, 45); {Force computation}
- SetF(systemFont,12,[bold]);
- theTB.IToggleButton(r,'Icon','I',f,toggleOff);
- fakeDlg.InstallItem(theTB);
- New(the3D);
- SetRect(r,125, 80,280, 80); {Force computation}
- SetF(systemFont,12,[italic]);
- the3D.IThreeDButton(r,'Window info','W',f);
- fakeDlg.InstallItem(the3D);
- New(theT3);
- SetRect(r,125,115,280,115); {Force computation}
- SetF(monaco,12,[outline]);
- theT3.IToggl3DButton(r,'Animation','A',f,
- toggleOff);
- fakeDlg.InstallItem(theT3);
- New(theST);
- SetRect(r,125,160,280,190);
- SetF(geneva,9,[]);
- theST.IStaticText(r,f,
- 'Alas & alack, these words are but static text.');
- fakeDlg.InstallItem(theST);
- New(theIC);
- SetRect(r,140,208,140,208);{Only top,left used}
- theIC.IIcon(r,blApplID);
- fakeDlg.InstallItem(theIC);
- New(theAN);
- SetRect(r,230,190,280,240);{Only top,left used}
- theAN.IAnimation(r,exclamationBaseID,
- exclamationNumber);
- fakeDlg.InstallItem(theAN);
- ShowWindow(fakeDlg.fWindow);
- END;
- END.
-